//
//  SCDiscountCollectionViewCell.m
//  LastOne
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCDiscountCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "NightHeader.h"
#import "NSString+EmString.h"
#import "FitHeader.h"
@interface SCDiscountCollectionViewCell ()

@property(nonatomic, retain)UILabel *label;

@end

@implementation SCDiscountCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _imageView = [[UIImageView alloc] init];
        [self addSubview:_imageView];
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.numberOfLines = 2;
        _nameLabel.font = [UIFont systemFontOfSize:16 * FitWidth];
        [self addSubview:_nameLabel];
        
        _priceoffLabel = [[UILabel alloc] init];
        _priceoffLabel.textColor = [UIColor redColor];
        _priceoffLabel.font = [UIFont systemFontOfSize:13 * FitWidth];
        [self addSubview:_priceoffLabel];
        
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.textColor = [UIColor redColor];
        _priceLabel.textAlignment = 2;
        _priceLabel.font = [UIFont systemFontOfSize:13 * FitWidth];
        [self addSubview:_priceLabel];
        
        _label = [[UILabel alloc] init];
        _label.font = [UIFont systemFontOfSize:13 * FitWidth];
        [self addSubview:_label];
        
        
        _imageView.frame = CGRectMake(5 * FitWidth, 5 * FitHeight, self.frame.size.width - 10 * FitWidth, 100 * FitHeight);
        
        _nameLabel.frame = CGRectMake(_imageView.frame.origin.x, _imageView.frame.origin.y + _imageView.frame.size.height, _imageView.frame.size.width, 50 * FitHeight);
        [_nameLabel NightWithType:UIViewColorTypeNormal];
        
        _priceoffLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height, 50 * FitWidth, 30 * FitHeight);
        
        _priceLabel.frame = CGRectMake(self.frame.size.width - 100 * FitWidth, _priceoffLabel.frame.origin.y, 60 * FitWidth, _priceoffLabel.frame.size.height);
        
        _label.frame = CGRectMake(_priceLabel.frame.origin.x + _priceLabel.frame.size.width, _priceLabel.frame.origin.y, 40 * FitWidth, _priceLabel.frame.size.height);
        [_label NightWithType:UIViewColorTypeNormal];
        _label.text = @"元起";
    }
    return self;
}

-(void)setGood:(GoodInfo *)good
{
    if (_good != good) {
        _good = good;
    }
    [_imageView sd_setImageWithURL:[NSURL URLWithString:good.photo] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    _nameLabel.text = good.title;
    _priceoffLabel.text = good.priceoff;
    _priceLabel.text = [NSString getStringByEmString:_good.price];
}

-(void)setKind:(NSInteger)kind
{
    _kind = kind;
    switch (kind) {
        case 0:
            _imageView.frame = CGRectMake(5 * FitWidth, 5, self.frame.size.width - 10 * FitWidth, 100 * FitHeight);
            _nameLabel.frame = CGRectMake(_imageView.frame.origin.x, _imageView.frame.origin.y + _imageView.frame.size.height, _imageView.frame.size.width, 40 * FitHeight);
            _nameLabel.font = [UIFont systemFontOfSize:15];
            _priceoffLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height, 50, 20);
            _priceLabel.frame = CGRectMake(self.frame.size.width - 100 * FitWidth, _priceoffLabel.frame.origin.y, 60 * FitWidth, _priceoffLabel.frame.size.height);
            _label.frame = CGRectMake(_priceLabel.frame.origin.x + _priceLabel.frame.size.width, _priceLabel.frame.origin.y, 40 * FitWidth, _priceLabel.frame.size.height);
            _label.text = @"元起";
            break;
            
        default:
            break;
    }
}


@end
